package cn.edu.tjufe.llp.tin.mapstruct;

import java.util.List;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.factory.Mappers;

import cn.edu.tjufe.llp.tin.dto.part04.BookDto;
import cn.edu.tjufe.llp.tin.model.bsc.BscBook;

@Mapper
public interface BookMapper {
	BookMapper INSTANCE = Mappers.getMapper( BookMapper.class );
    
    // @Mapping(source = "numberOfSeats", target = "seatCount")
    BookDto toBookDto(BscBook book);

    @Mapping(target = "chapters", ignore = true)		    // 忽略掉chapters
    BscBook ToBscBook(BookDto book);
    
    List<BookDto> toBookDtoList(List<BscBook> books);
    
    @Mapping(target = "id", ignore = true)		    // 忽略掉id
    @Mapping(target = "deleted", ignore = true)		// 忽略掉id
    void updateModel(BookDto source, @MappingTarget BscBook target);
}
